<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <contextName>logback</contextName>
    <property name="LOG_HOME" value="logs"/>
    <property name="FILE_NAME" value="default"/>

    <!-- 控制台输出 -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <!--格式化输出：%d表示日期，%thread表示线程名，%-5level：级别从左显示5个字符宽度%msg：日志消息，%n是换行符-->
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%line - %msg  %n</pattern>
        </encoder>
    </appender>

    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${r'${LOG_HOME}'}/${r'${FILE_NAME}'}.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <!-- rollover daily -->
            <fileNamePattern>${r'${LOG_HOME}'}/${r'${FILE_NAME}'}.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
            <!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
            <maxFileSize>100MB</maxFileSize>
            <maxHistory>30</maxHistory>
            <totalSizeCap>2GB</totalSizeCap>
            <cleanHistoryOnStart>true</cleanHistoryOnStart>
        </rollingPolicy>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%line - %msg%n</pattern>
        </encoder>
<#--        <filter class="ch.qos.logback.classic.filter.LevelFilter">-->
<#--            <level>info</level>-->
<#--            <onMatch>ACCEPT</onMatch>-->
<#--            <onMismatch>DENY</onMismatch>-->
<#--        </filter>-->
    </appender>

    <logger name="${pkgName}" level="info"/>
    <logger name="org.springframework.web" level="info" additivity="true"/>
    <logger name="org.apache.ibatis" level="info" additivity="true"/>
    <logger name="org.springframework.boot" level="info" additivity="true"/>

    <root level="info">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="FILE"/>
    </root>

</configuration>